﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Configuration;
using LKVMLMLib;
using TrucTiepService;

namespace Schedule
{
    class Program
    {
        static void Main(string[] args)
        {

            calculatorDaily();
            //if (DateTime.Now.Date.Day == 17 && DateTime.Now.Date.Month == 9 && DateTime.Now.Date.Year == 2016)
            //rexecuteRemake();

        }
        public static void calculatorMonth()
        {
           
            int month = DateTime.Now.Month;
            int year = DateTime.Now.Year;

            var url = ConfigurationManager.AppSettings["profiturl"];
            url = string.Format(url + "ExecuteMonthly?month={0}&year={1}", month, year);
            var client = new WebClient();
            var content = client.DownloadString(url);

        }
        public static void calculatorDaily()
        {
            
            DateTime date = DateTime.Now;

            var url = ConfigurationManager.AppSettings["profiturl"];
            var client = new MyWebClient();
            url = string.Format(url + "ExecuteDaily?day={0}&month={1}&year={2}", date.Day, date.Month, date.Year);
            var content = client.DownloadString(url);            
            
        }
        public static void rexecuteRemake()
        {

            DateTime date = DateTime.Now;

            var url = ConfigurationManager.AppSettings["profiturl"];
            var client = new MyWebClient();
            url = string.Format(url + "executeRemake?day={0}&month={1}&year={2}", date.Day, date.Month, date.Year);
            var content = client.DownloadString(url);

        }

    }
    class MyWebClient : WebClient
    {
        protected override WebRequest GetWebRequest(Uri uri)
        {
            WebRequest w = base.GetWebRequest(uri);
            w.Timeout = 60 * 60 * 1000;
            return w;
        }
    }
}
